#!/bin/bash
# ============================================================
# Script Name:    imuBringup.sh
# Description:    根据ROS参数动态启动不同类型的IMU驱动
#                 支持标准IMU、SICK磁力IMU和TL720D等多种型号
# Author:         haibo
# Created Date:   2025-07-24
# Version:        1.0
# Modified Date:  2025-09-09
# Modified By:    haibo
# Modification:   初始版本
# Usage:          ./imuBringup.sh [日志文件路径]
# Notes:          1. 依赖ROS参数服务器中的/IMU/StartupType配置
#                 2. 需要common.sh公共函数库支持
#                 3. 支持imu, sick_mag_imu, tl720d三种类型
# ============================================================
source ${HOME}/lgimRobot/bin/common "$@"

main() {
    local imu_type=$(get_ros2_param "IMU.StartupType.value")
    [ -z "$imu_type" ] && { 
        log "ERROR" "未定义IMU类型" 
        return 1 
    }

    case "$imu_type" in
        "imu") 
            launch_node "标准IMU" ros2 run imu_driver imu_node ;;
        "sick_mag_imu")
            launch_node "SICK磁力IMU" ros2 run imu_driver sick_mag_imu_node ;;
        "tl720d")
            launch_node "TL720D IMU" ros2 run imu_driver imu_tl720d_node ;;
        *) 
            log "ERROR" "未知IMU类型: $imu_type" 
            return 2 ;;
    esac
    return $?
}

main